package code1_100.code1_10;

import java.util.*;

public class Code3 {
    //无重复字符的最长子串
    static class Solution {
        public int lengthOfLongestSubstring(String s) {
            int r = 0, l = 0, res = 0;
            HashSet<Character> set = new HashSet<>();
            while(r<s.length()){
                char c = s.charAt(r++);
                while(set.contains(c)){
                    set.remove(s.charAt(l++));
                }
                set.add(c);
                res = Math.max(res,set.size());
            }
            return res;
        }


    }
    public static void main(String[] args) {
        System.out.println(new Solution().lengthOfLongestSubstring("abcabcbb"));
    }
}


